﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bussiness;

namespace WebApplication.Admin
{
    public partial class BaoCaoCongNoNhaCungCap : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadNhacc();
            }
        }
        public void LoadNhacc()
        {
            IUnitOfWork iunitfwork = new EFUnitOfWork();
            NHACUNGCAPRepository repository = new NHACUNGCAPRepository(new EFRepository<NHACUNGCAP>(), iunitfwork);
            IQueryable<NHACUNGCAP> objNhacungcap = repository.All();
            Dlnhacc.DataSource = objNhacungcap;
            Dlnhacc.DataValueField = "MANCC";
            Dlnhacc.DataTextField = "TENNCC";
            Dlnhacc.DataBind();
            Dlnhacc.Items.Insert(0, new ListItem {Text="---Chọn nhà cung cấp---", Value="0" });
        }
        protected void lbtnxem_Click(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            string ngay = dt.ToString("dd/MM/yyyy");
            if (Dlnhacc.SelectedValue.Equals("0"))
            {
                RegisterClientScriptBlock("Thông báo", "<script> alert('Vui lòng chọn nhà cung cấp')</script>");
                return;
            }
            string mancc=Dlnhacc.SelectedValue;
            var source = new Microsoft.Reporting.WebForms.ReportDataSource("BaoCaoCOngNoNhacc", new Baocao.BaoCaoCongNoNhaCungCap().GetBaoCaoCongNoNcc(ngay,mancc));
            ReportViewer1.LocalReport.ReportPath=@"Admin\Baocao\BaoCaoCongNoNhaCC.rdlc";
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(source);
            ReportViewer1.LocalReport.Refresh();


        }
    }
}